package com.shujia.sink

import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.api.common.serialization.SimpleStringSchema

object Demo1Sink {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    env.setParallelism(1)
    val ds = env.socketTextStream("node1", 8888)

    // 在taskManager  中打印结果
    ds.print()

    //保存到文件   每一个线程都会产生一个文件
    ds.writeAsText("flink/data/out").setParallelism(1)

    //ds.writeToSocket("node1", 7777, new SimpleStringSchema())

    env.execute("Demo1Sink")
  }
}
